import QtQuick 2.9
import QtQuick.Controls 2.5

Rectangle {
    id: root
    color: "#99333333"

    signal clickedOK()

    function show(title, message) {
        root.visible = true
        txtText.text = message

        if (title) {
            txtTitle.text = title
            txtTitle.visible = true
        } else {
            txtTitle.visible = false
        }
    }

    ///////////////////////////////////////////////

    MouseArea {
        anchors.fill: parent
        acceptedButtons: Qt.AllButtons
        hoverEnabled: true
        onClicked: {}
        onPressed: {}
        onReleased: {}
    }

    Rectangle {
        id: layoutContent
        width: parent.width * 0.6
        height: parent.height * 0.4
        anchors.centerIn: parent

        color: "#f1f1f1"
        radius: 10

        Column {
            anchors.fill: parent
            Text {
                id: txtTitle
                width: parent.width
                height: parent.height * 0.2
                horizontalAlignment: Text.AlignHCenter
                verticalAlignment: Text.AlignVCenter
                font.pixelSize: height * 0.5
                text: qsTr("关于")
            }
            Rectangle {
                width: parent.width; height: 1
                color: "#999"
            }
            Text {
                id: txtText
                width: parent.width
                height: txtTitle.visible ? parent.height * 0.6 : parent.height * 0.8
                font.pixelSize: txtTitle.height * 0.3
                horizontalAlignment: Text.AlignHCenter
                verticalAlignment: Text.AlignVCenter
                leftPadding: width * 0.05
                rightPadding: width * 0.05
                wrapMode: Text.Wrap
                elide: Text.ElideRight
                text: qsTr("速析能 HPY 检测仪\nv1.0.0")
            }
            Rectangle {
                width: parent.width; height: 1
                color: "#999"
            }

            FlatButton {
                width: parent.width
                height: parent.height * 0.2
                text: qsTr("確定")
                textColor: "#2E75B6"
                backgroundColor: "transparent"
                onClicked: {
                    root.visible = false
                    clickedOK()
                }
            }
        }
    }
}
